<template>
    <div class="mfa-guide">
        <div class="guide-section">
            <h3 class="guide-title">什么是两步验证 (2FA)?</h3>
            <p class="guide-description">
                两步验证(2FA)是一种额外的安全层，可以保护您的帐户免受未经授权的访问。启用后，除了常规密码外，您还需要输入一个临时验证码才能登录。
            </p>
        </div>

        <div class="guide-section">
            <h3 class="guide-title">如何设置两步验证?</h3>
            <div class="guide-steps">
                <div class="step-item">
                    <div class="step-number">1</div>
                    <div class="step-content">
                        <h4 class="step-title">下载身份验证器应用</h4>
                        <p class="step-description">
                            在您的手机上安装一个身份验证器应用，例如：
                        </p>
                        <div class="app-list">
                            <div class="app-item">
                                <i class="fab fa-android"></i> Authing令牌
                            </div>
                            <div class="app-item">
                                <i class="fab fa-google"></i> Google Authenticator
                            </div>
                            <div class="app-item">
                                <i class="fab fa-microsoft"></i> Microsoft Authenticator
                            </div>
                        </div>
                    </div>
                </div>

                <div class="step-item">
                    <div class="step-number">2</div>
                    <div class="step-content">
                        <h4 class="step-title">扫描QR码</h4>
                        <p class="step-description">
                            使用身份验证器应用扫描我们提供的QR码，或手动输入提供的密钥。
                        </p>
                    </div>
                </div>

                <div class="step-item">
                    <div class="step-number">3</div>
                    <div class="step-content">
                        <h4 class="step-title">输入验证码</h4>
                        <p class="step-description">
                            在身份验证器应用中获取6位验证码，输入验证码完成设置。
                        </p>
                    </div>
                </div>
            </div>
        </div>

        <div class="guide-section">
            <h3 class="guide-title">重要提示</h3>
            <div class="guide-tips">
                <div class="tip-item">
                    <i class="el-icon-warning"></i>
                    <p>请保存好您的备份码或秘钥，以防您丢失手机或无法访问身份验证器应用。</p>
                </div>
                <div class="tip-item">
                    <i class="el-icon-time"></i>
                    <p>验证码每30秒更新一次，请确保输入最新的验证码。</p>
                </div>
                <div class="tip-item">
                    <i class="el-icon-mobile-phone"></i>
                    <p>如果您更换手机，请记得迁移您的身份验证器账户或使用备份码重新设置。</p>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'MfaGuide'
}
</script>

<style lang="scss" scoped>
.mfa-guide {
    padding: 16px 0;

    .guide-section {
        margin-bottom: 32px;

        &:last-child {
            margin-bottom: 0;
        }
    }

    .guide-title {
        font-size: 18px;
        font-weight: 600;
        margin: 0 0 16px;
        color: var(--text-primary, #303133);
        position: relative;
        padding-left: 16px;

        &::before {
            content: '';
            position: absolute;
            left: 0;
            top: 6px;
            bottom: 6px;
            width: 4px;
            background-color: var(--primary-color, #409eff);
            border-radius: 2px;
        }
    }

    .guide-description {
        font-size: 15px;
        line-height: 1.6;
        color: var(--text-secondary, #606266);
        margin: 0 0 16px;
    }

    .guide-steps {
        .step-item {
            display: flex;
            margin-bottom: 24px;

            &:last-child {
                margin-bottom: 0;
            }
        }

        .step-number {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--primary-color, #409eff);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            margin-right: 16px;
            flex-shrink: 0;
        }

        .step-content {
            flex: 1;
        }

        .step-title {
            font-size: 16px;
            font-weight: 600;
            margin: 0 0 8px;
            color: var(--text-primary, #303133);
        }

        .step-description {
            font-size: 14px;
            line-height: 1.6;
            color: var(--text-secondary, #606266);
            margin: 0;
        }
    }

    .app-list {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        margin-top: 12px;

        .app-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            background-color: var(--bg-light, #f5f7fa);
            border-radius: 4px;
            font-size: 14px;

            i {
                font-size: 16px;
                color: var(--primary-color, #409eff);
            }
        }
    }

    .guide-tips {
        background-color: var(--bg-light, #f5f7fa);
        border-radius: 8px;
        padding: 16px;

        .tip-item {
            display: flex;
            margin-bottom: 12px;

            &:last-child {
                margin-bottom: 0;
            }

            i {
                color: var(--warning-color, #e6a23c);
                font-size: 18px;
                margin-right: 12px;
                margin-top: 2px;
                flex-shrink: 0;
            }

            p {
                margin: 0;
                font-size: 14px;
                line-height: 1.6;
                color: var(--text-secondary, #606266);
            }
        }
    }
}

// 暗色模式适配
@media (prefers-color-scheme: dark) {
    .mfa-guide {
        .guide-title {
            color: var(--text-primary-dark, #e0e0e0);
        }

        .guide-description,
        .step-description,
        .tip-item p {
            color: var(--text-secondary-dark, #a0a0a0);
        }

        .step-title {
            color: var(--text-primary-dark, #e0e0e0);
        }

        .app-list .app-item {
            background-color: rgba(255, 255, 255, 0.05);
        }

        .guide-tips {
            background-color: rgba(255, 255, 255, 0.05);
        }
    }
}

.dark-mode {
    .mfa-guide {
        .guide-title {
            color: var(--text-primary-dark, #e0e0e0);
        }

        .guide-description,
        .step-description,
        .tip-item p {
            color: var(--text-secondary-dark, #a0a0a0);
        }

        .step-title {
            color: var(--text-primary-dark, #e0e0e0);
        }

        .app-list .app-item {
            background-color: rgba(255, 255, 255, 0.05);
        }

        .guide-tips {
            background-color: rgba(255, 255, 255, 0.05);
        }
    }
}
</style>